//
// Created by yangchao on 2022/7/14.
// 232. 用栈实现队列: https://leetcode.cn/problems/implement-queue-using-stacks/
//
#include <stack>
using namespace std;

class MyQueue {
public:
    stack<int> sk1;
    stack<int> sk2;

    MyQueue() {

    }

    void push(int x) {
        sk1.push(x);
    }

    int pop() {
        if (sk2.empty()) {
            while (!sk1.empty()) {
                sk2.push(sk1.top());
                sk1.pop();
            }
        }
        int res = sk2.top();
        sk2.pop();
        return res;
    }

    int peek() {
        int res = this->pop();
        sk2.push(res);
        return res;
    }

    bool empty() {
        return sk1.empty() && sk2.empty();
    }
};

